﻿using System;

using BizElements.BusinessLayer;

namespace BizElements.Web
{
    /// <summary>
    /// Control property bound to a business object field (see: <see cref="IBindableField"/>).
    /// </summary>
    /// <remarks>This is the property which displays the value contained in the business class property.</remarks>
    internal interface IControlPropertyBinder
    {
        /// <summary>
        /// Gets the value stored in the control.
        /// </summary>
        /// <param name="control">Control.</param>
        /// <param name="controlPropertyName">Control property.</param>
        /// <param name="outputDataType">Type of the value that the method will return.</param>
        /// <param name="formatter">The <see cref="IMessageFormatter"/> object used to format the bound values.</param>
        /// <param name="errorCode">A value indicating the type of error encountered during parsing.</param>
        /// <returns>Value stored in the control. <b>null</b> if control is empty.</returns>
        object GetValue(IBoundControl control, string controlPropertyName, Type outputDataType, IMessageFormatter formatter, out ParseError errorCode);

        /// <summary>
        /// Sets and display the given value.
        /// </summary>
        /// <param name="control">Control.</param>
        /// <param name="controlPropertyName">Control property.</param>
        /// <param name="val">Value to be displayed by the control.</param>
        /// <param name="formatter">The <see cref="IMessageFormatter"/> object used to format the bound values.</param>
        void SetValue(IBoundControl control, string controlPropertyName, object val, IMessageFormatter formatter);
    }
}